import * as zrender from "zrender";
import { initLastScrollX, todayOffset } from "../config";
import { getRandomColor } from "../utils";

/**
 * 初始化ZRender实例
 */
export function initializeZRender() {
  const zr = zrender.init(document.getElementById("zrender-container"), {
    renderer: 'canvas'
  });
  return zr;
}


/**
 * 初始化任务数据
 * @returns {Array} 任务数组
 */
export function initializeTasks() {
  const tasks: Task[] | {}[] = [
    { name: "Task 1", start: todayOffset + 0, duration: 3, resource: "John", fillColor: getRandomColor() },
    { name: "Task 2", start: todayOffset + 2, duration: 4, resource: "Jane", fillColor: getRandomColor() },
    { name: "Task 3 long long long", start: todayOffset + 7, duration: 1, resource: "Bob", fillColor: getRandomColor() },
    { name: "Task 4", start: todayOffset + 8, duration: 2, resource: "Bose", fillColor: getRandomColor() },
    { name: "Task 5", start: todayOffset + 10, duration: 3, resource: "Uno", fillColor: getRandomColor() },
    {}
  ];

  return tasks;
}


/**
 * 初始化滚动位置
 * @returns {Object} 滚动位置对象
 */
export function initializeScrollPosition(): ScrollState {
  return {
    lastScrollX: 0 + initLastScrollX,
    lastScrollY: 0
  };
}

